package com.pro.control;

import com.pro.entity.JsProductCategroy;
import com.pro.entity.JsonData;
import com.pro.service.JsProductCategroyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * auther 杨沛琪
 * createDate 2021/12/9
 */
@Controller
@RequestMapping("/JsProductCategroy")
public class JsProductCategroyController {
    @Autowired
    private JsProductCategroyService jsProductCategroyService;

    //获取商品名称
    @RequestMapping("/getTitle")
    @ResponseBody
    public JsonData getTitle(){
        List<JsProductCategroy> title = jsProductCategroyService.getTitle();
        System.out.println(title);
        return title!=null?JsonData.buildSuccess(title):JsonData.buildError("服务器错误");
    }

    //获取商品点击次数
    @RequestMapping("/getHits")
    @ResponseBody
    public JsonData getHits(){
        List<JsProductCategroy> title = jsProductCategroyService.getHits();
        return title!=null?JsonData.buildSuccess(title):JsonData.buildError("服务器错误");
    }

    //获取商品收藏次数
    @RequestMapping("/getCollection")
    @ResponseBody
    public JsonData getCollection(){
        List<JsProductCategroy> title = jsProductCategroyService.getCollection();
        return title!=null?JsonData.buildSuccess(title):JsonData.buildError("服务器错误");
    }
}
